package com.tul.exercise.base.swing;

import javax.swing.*;
import java.util.concurrent.TimeUnit;

/**
 * @Description 《java编程思想》第22章 示例3：
 *
 * 显示标签
 **/
public class SubmitLabelManipulationTask {
    public static void main(String[] args) throws Exception{
        JFrame frame = new JFrame("HelloSwing");
        JLabel label = new JLabel("A Label");

        frame.add(label);

        // 设置退出
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300, 100);
        // 使界面可见
        frame.setVisible(true);

        TimeUnit.SECONDS.sleep(1);
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                label.setText("Hey! This is Different!");
            }
        });

    }
}
